import { config, cdnBase } from '../../config/index';

/** 获取首页数据 */
function mockFetchHome() {
  const { delay } = require('../_utils/delay');
  const { genSwiperImageList } = require('../../model/swiper');

  return delay().then(() => {
    return {
      swiper: genSwiperImageList(),
      tabList: [
        {
          text: '生禽鱼鲜',
          key: 0,
        },
        {
          text: '时蔬瓜果',
          key: 1,
        },
        {
          text: '粮油米面',
          key: 2,
        },
        {
          text: '酒类调味',
          key: 3,
        }
      ],
      activityImg: `${cdnBase}/activity/banner.png`,
    };
  });
}

/** 获取首页数据 */
export function fetchHome() {
  if (config.useMock) { // 线下开发假数据
    return mockFetchHome();
  }
  // 线上
  return new Promise((resolve) => {
    resolve('real api');
    /*
{
      swiper: genSwiperImageList(),
      if（key == 0）{
        刷新列表（key）；
      }

      tabList: [
        {
          text: '生禽鱼鲜',
          key: 0,
        },
        {
          text: '时蔬瓜果',
          key: 1,
        },
        {
          text: '粮油米面',
          key: 2,
        },
        {
          text: '酒类调味',
          key: 3,
        }
      ],
      activityImg: `${cdnBase}/activity/banner.png`,
    }
    */
  });
}
